import { User, UserProfile } from "@/types/data";
import { RootAction } from "@/types/store";

type stateType = {
    user: User
    userProfile: UserProfile
}
const initValue =  {
    // 用户基本资料
    user: {} as User,
    // 用户详细资料
    userProfile: {} as UserProfile
}
export default function profileReducer(state: stateType = initValue, action: RootAction) {
  if(action.type === 'profile/set_user') {
    return {
        ...state,
        user: action.payload
    }
  }

  if(action.type === 'profile/set_user_profile') {
    return {
        ...state,
        userProfile: action.payload
    }
  }

  return state
}
